﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ADOcaiwenlong
{
    public class Class1
    {
        private string abcc= "select*from User";
        private string abcd = "server=.;datebase=sdas;uid=sa;pwd=123456";

        public static void Abb() {
            string abcc = "server=.;datebase=sdas;uid=sa;pwd=123456";
            SqlConnection abcd = new SqlConnection(abcc);
            abcd.Open();
            var abcde = "select*from userinfo";
            SqlCommand sqlCommand = new SqlCommand(abcc, abcd);
            var cnn = sqlCommand.ExecuteReader();
            Console.WriteLine("{0}\t{1}\t{2}", "ID", "名字", "性别");
            while (cnn.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}", "cnn[id],cnn[name],cnn[sex]");


            }
            abcd.Close();

        }
        public void bbbb()
        {
           
            SqlDataAdapter aaa = new SqlDataAdapter(abcc, abcd);
            DataTable bbb = new DataTable();

            aaa.Fill(bbb);
          
            Console.WriteLine("{0}\t{1}\t{2}", "ID", "名字");
            for (int i = 0; i < bbb.Rows.Count; i++)
            {
                Console.WriteLine("{0}\t{1}\t{2}", bbb.Rows[i]["ID"], bbb.Rows[i]["Name"]);
            }

        }

       
    }
}